package com.example.administrator.appstpremvpdemo.model;

import com.example.administrator.appstpremvpdemo.contract.HomefragentContract;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author Administrator
 * @Date 2017/12/25
 * @description
 * @function
 */

public class HomefragentModel implements HomefragentContract.Model {

    HomefragentContract.Presenter mPresenter;
    String mUrl;
    private HashMap<String, String> mParms;

    public HomefragentModel(HomefragentContract.Presenter presenter, String url) {
        this.mPresenter = presenter;
        this.mUrl = url;
    }

    public void setRequestParms(HashMap<String ,String> parms) {
        this.mParms = parms;
        if (mParms==null) {
            mParms = new HashMap<>();
        }
    }

    @Override
    public void start() {
        requestData();
    }

    @Override
    public void destroy() {
        mPresenter = null;
    }

    @Override
    public void requestData() {
        //TODO 获取数据
        List<String> mList = new ArrayList<>();
        for (int i = 0; i<30 ; i++) {
            mList.add(""+i);
        }
        mPresenter.showList(mList);
    }

    @Override
    public void requestPullLoadMoreData() {
        //TODO 操作
        mPresenter.start();
    }
}
